package com.xuecheng.content.feignclient;

import com.xuecheng.content.model.po.CourseIndex;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @ClassName SearchFallbackFactory
 * @Description TODO
 * @Author kiku
 * @Date 2024/9/23 22:37
 * @Version 1.0
 */
@Component
@Slf4j
public class SearchFallbackFactory implements FallbackFactory<SearchServiceClient> {
    @Override
    public SearchServiceClient create(Throwable throwable) {
        return new SearchServiceClient() {
            @Override
            public Boolean add(CourseIndex courseIndex) {
                log.info("添加课程索引发生熔断，执行降级策略");
                log.error(throwable.getMessage());
                return false;
            }
        };


    }
}
